
#pragma once
#include <memory>
#include <string>
#include <functional>
#include "IPAddress.h"
#include "Socket.h" 
#include "EventLoop.h"
#include "Channel.h"

namespace net
{

using namespace utils;

class Acceptor : public std::enable_shared_from_this<Acceptor>
{
public:
    using ptr = std::shared_ptr<Acceptor>;

    Acceptor(EventLoop::ptr ptrEventLoop, IPAddress::ptr ptrAddr);
    ~Acceptor();


    void startAccept();
    void setNewConnectionCB(std::function<void(Socket::ptr)> cb);
    void handleEvent();

private:
    Socket::ptr m_ptrSock;
    Channel::ptr m_ptrChannel;
    EventLoop::ptr m_ptrEventLoop;
    std::function<void(Socket::ptr)> m_newConnectionCB;
};

    
} // namespace net